# Maintainer: Laurent Carlier <lordheavym@gmail.com>
# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Vesa Kaihlavirta <vegai@iki.fi>

pkgname=openttd
pkgver=13.1
pkgrel=1
pkgdesc='Engine for running Transport Tycoon Deluxe'
arch=(loong64 x86_64)
url='https://www.openttd.org'
license=(GPL)
depends=(fluidsynth fontconfig hicolor-icon-theme)
makedepends=(cmake ninja)
optdepends=('openttd-opengfx: free graphics'
            'openttd-opensfx: free soundset')
source=("https://cdn.$pkgname.org/$pkgname-releases/$pkgver/$pkgname-$pkgver-source.tar.xz")
b2sums=('2d289defa38583c95f90322964ba43756468d7fa50087267119f00ccc3688e68e22631f41b091d44b1afaa878f8621f27ba58a0623d5be9420b61833dba8d6e7')

prepare() {
  sed -i '/sse/d;/SSE/d' $pkgname-$pkgver/CMakeLists.txt
}

build() {
  cmake \
    -B build \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_BINDIR=bin \
    -D CMAKE_INSTALL_DATADIR=/usr/share \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -G Ninja \
    -S $pkgname-$pkgver
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
}
